﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Data.SqlClient;
namespace _2014112107
{
    public partial class Register : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string strCn = "server=pc.hstc.cn;database=dhd2014112107;uid=2014112107;password=19951106";
            SqlConnection cn = new SqlConnection(strCn);
            try
            {
                cn.Open();
                string strUserName = this.txtUserName.Text;
                string strPwd = this.txtPwd.Text;
              
                string strName = this.txtName.Text;
                string strPhone = this.txtPhone.Text;
                string strMemo = this.txtMemo.Text;
                string Gender = Request.QueryString["Gender"];
                if (rdoMan.Checked)
                {
                    Gender = "男";

                }
                else
                {
                    Gender = "女";
                }
                string strSql = "INSERT INTO UserInfo  (UserName, Password, Name, Gender, Memo, Phone)  VALUES   (N'" + strUserName + "',N'" + strPwd + "',N'" + strName + "',N'" + Gender + "',N'" + strMemo + "',N'" + strPhone + "')";
                SqlCommand cmd = new SqlCommand(strSql, cn);
                SqlDataReader dr = cmd.ExecuteReader();
                this.Response.Write(" <script language=javascript>alert('注册成功！点击确定进入登录界面！');window.window.location.href='Index.aspx';</script> ");

            }
            //lblInfo.Text = "本页已通过验证！";
            catch 
            {
                Response.Write("<script>alert('注册失败！请重新注册！');</script>");
            }
            finally 
            {
                cn.Close();
            }
        }

        protected void Timer1_Tick(object sender, EventArgs e)
        {
            lblShowTime.Text = System.DateTime.Now.ToString();
            

        }

       
    }
}